//
//  CTPCalloutModel.m
//  citipad
//
//  Created by Chih Yuan Liu on 3/14/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "CTPCalloutModel.h"
#import "JSON.h"


@implementation CTPCalloutModel

-(id)initWithJSON:(NSString *)json{
	if (self = [super init]){
		NSDictionary *dictionary = [json JSONValue];
		NSArray *jdata = [dictionary objectForKey:@"data"];
		NSEnumerator *enumerator = [jdata objectEnumerator];
		NSDictionary* item;
		array = [[NSMutableArray alloc] init];
		while (item = (NSDictionary*)[enumerator nextObject]) {
			CTPCallout * callout = [[CTPCallout alloc] init];
			callout.latitude = [(NSString*)[item objectForKey:@"latitude"] floatValue];
			callout.longtitude = [(NSString*)[item objectForKey:@"longtitude"] floatValue];
			callout.title = (NSString*)[item objectForKey:@"title"];
			callout.subtitle = (NSString*)[item objectForKey:@"subtitle"];
			[array addObject:callout];
		}
    }
    return self;
}

-(NSInteger) GetCount{
	return [array count];
}

-(CTPCallout*) GetItemAtIndex:(int)index{
	CTPCallout *v = [array objectAtIndex:index];
	return v;
}

@end
